package com.demo.morning;

import java.math.BigInteger;
import java.util.Arrays;
import java.util.List;

/**
 * @ClassName Test1
 * @Description TODO
 * @Author tianqinglong
 * @Date 10:24 2022/7/12
 * @Version 1.0
 **/
public class Test1 {
    public static void main(String[] args) {
        终止操作reduce();
    }

    private static void 终止操作reduce() {
        List<BigInteger> list = Arrays.asList(new BigInteger("10"),
                new BigInteger("20"),
                new BigInteger("30"),
                new BigInteger("40"));
        BigInteger reduce2 = list.stream().reduce(new BigInteger("0"), (b1, b2) -> {
            return b1.add(b2);
        });
        System.out.println(reduce2);

        BigInteger reduce = list.stream().reduce(BigInteger.ZERO, BigInteger::add);
        System.out.println("和"+reduce);

        BigInteger reduce1 = list.stream().reduce(BigInteger.ONE, BigInteger::multiply);
        System.out.println("乘积"+reduce1);
    }
}
